<template>
	<view class="container">
		<view class="top-part">
			<view class="img-wrap">
				<image style="width: 200rpx; height: 200rpx;"  src="/static/imgnew/logo.png"></image>
			</view>
			<view class="sub-title">
				[助力水土保持监测]
			</view>
			<view style="font-weight:normal;margin-top:10rpx;text-align: center;">江西省水利科学院</view>
			
			<view class="big-title">
				水土保持研究所整编系统
			</view>
			<div class="line-title">
				
			</div>
			
			
		</view>
		<view class="input-wrap" style="margin-top:120rpx">
			<view class="left-label">
				<image style="width: 35rpx; height: 35rpx;margin:0 32rpx"  src="/static/imgnew/icon_supplier.png"></image>
			</view>
			<input class="uni-input" v-model="mobile"  placeholder="账号" />
		</view>
		
		<view class="input-wrap" style="margin-top:80rpx">
			<view class="left-label">
				<image style="width: 35rpx; height: 35rpx;margin:0 32rpx"  src="/static/imgnew/icon_supplier.png"></image>
			</view>
			<input class="uni-input" v-model="pwd" :password="isshowpwd" type="text"  placeholder="密码" />
			<view class="left-label">
				<image v-show="isshowpwd" @click="isshowpwd=!isshowpwd" style="width: 36rpx; height: 28rpx;margin:0 32rpx"  src="/static/imgnew/icon_ show.png"></image>
				<image v-show="!isshowpwd" @click="isshowpwd=!isshowpwd" style="width: 36rpx; height: 18rpx;margin:0 32rpx"  src="/static/imgnew/icon_hide.png"></image>
			</view>
		</view>
		
		
		
		<view class="sub-btn" @tap="loginClick">
			
		</view>
		
		
		<view class="bottom-part">
			<view>科技水保 数字水保</view>
			<view>智慧水保 科学水保</view>
			
			<view>V1.1.0</view>
		</view>
	</view>
</template>

<script>
	function ToDigital(strDu, strFen, strMiao, len) {
	  len = (len > 6 || typeof(len) == "undefined") ? 6 : len; //精确到小数点后最多六位   
	  strDu = (typeof(strDu) == "undefined" || strDu == "") ? 0 : parseFloat(strDu);
	  strFen = (typeof(strFen) == "undefined" || strFen == "") ? 0 : parseFloat(strFen) / 60;
	  strMiao = (typeof(strMiao) == "undefined" || strMiao == "") ? 0 : parseFloat(strMiao) / 3600;
	  var digital = strDu + strFen + strMiao;
	  if (digital == 0) {
	    return "";
	  } else {
	    return digital.toFixed(len);
	  }
	}
	import md5 from './md5.js'
	export default{
		data(){
			return {
				isshowpwd:true,
				isshow:false,
				checkra:'',
				mobile: '',
				pwd: '',
				logining: false
			}
		},
		onLoad(){
			if (process.env.NODE_ENV === 'development') {
			
				this.mobile='陈东'
				this.pwd='Jxsky8888'
				this.checkra=true
			
			}
		},
		methods: {
			getuserinfo(){
				let that=this
				that.apipost('/soil/water/sys/login/getCurrentUser',{
					loginName:that.mobile,
					password:md5.hex_md5(that.pwd)
				},false).then(res => {
					
					
					if(res.code==1){
						
						uni.setStorageSync("longitude",ToDigital(res.object.stcdList[0].longitude.split('°')[0],res.object.stcdList[0].longitude.split('°')[1].split('′')[0],res.object.stcdList[0].longitude.split('′')[1].split('\"')[0]))
						uni.setStorageSync("latitude",ToDigital(res.object.stcdList[0].latitude.split('°')[0],res.object.stcdList[0].latitude.split('°')[1].split('′')[0],res.object.stcdList[0].latitude.split('′')[1].split('\"')[0]))
						uni.setStorageSync("userinfo",JSON.stringify(res.object))
						uni.setStorageSync("user",JSON.stringify(that.mobile))
						uni.switchTab({
						    url: '/pages/index/index'
						});
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			loginClick(){
				
				
				let that=this
				if(this.mobile==''||this.pwd==''){
					uni.showToast({
					    title: '账号密码不能为空',
					    duration:4000,
						icon:'none'
					});
					return
				}
				
				that.apiget('/soil/water/sys/login/doLogin',{
					loginName:that.mobile,
					password:md5.hex_md5(that.pwd)
				},false).then(res => {
					console.log(res)
					
					if(res.code==1){
						uni.setStorageSync("auth_token",res.object)
						that.getuserinfo()
						//uni.setStorageSync("mobile",that.mobile)
						// uni.switchTab({
						//     url: '/pages/index/index'
						// });
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			
			enterpage(path){
				
				if(path){
					
					uni.navigateTo({
					    url: path
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			}
			
		},

	}
</script>

<style lang='scss'>
	.bottom-part{
		text-align: center;
		position:fixed;
		bottom:0;
		width:100%;
	}
	.sub-btn{
		width:564rpx;
		height:186rpx;
		background: url(/static/imgnew/Btn_Bg.png) no-repeat center;
		background-size:100% 100%;
		display:flex;
		box-sizing: border-box;
		padding-top:59rpx;
		margin:0 auto;
		color:#fff;
		justify-content: center;
		margin-top:30rpx;
	}
	.input-wrap{
		margin:0 auto;
		width: 520rpx;
		height: 100rpx;
		border-radius: 55rpx;
		border: 2rpx solid #72BB57;
		display:flex;
		align-items: center;
	}
	.sub-title{
		padding-top:22rpx;
		text-align: center;
	}
	.line-title{
		margin:0 auto;
		width: 60rpx;
		height: 8rpx;
		background: #3F8CFF;
		border-radius: 4px;
	}
	.big-title{
		margin-top:120rpx;
		margin-bottom:10rpx;
		text-align: center;
	}
	page{
		height:100%;
		overflow: hidden;
	}
	.top-part{
		height:428rpx;
		position:relative;
		font-size:36rpx;
		font-weight: bold;
	}
	.container{
		height:100%;
		background:url(/static/imgnew/Wave.png) no-repeat center 0;
		background-size:100% 548rpx;
		padding-top:140rpx;
	}
	.img-wrap{
		display:flex;
		justify-content: center;
	}
</style>
